/// @tags: Divide on SegmentTree Bitset XOR
#include <bitset>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

using std::cin;
using std::cout;

namespace BlueQuantum {

constexpr int MAXN = 5e2 + 3, MAXQ = 1e3 + 3, LEN = 1e3 + 3;

typedef std::bitset<LEN> bitset;

bitset w[MAXN];

namespace UFS {

int fa[MAXN];

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

inline void init(int n) {
  for (int i = 1; i <= n; ++i) fa[i] = i;
}

}  // namespace UFS
using UFS::find;

struct Graph {
  struct Edge {
    int v, nxt;
    const bitset *w;
  };

  int ecnt, heads[MAXN];
  Edge e[MAXN * 2];

  inline int &operator()(int index) { return heads[index]; }
  inline Edge &operator[](int index) { return e[index]; }

  inline void add(int u, int v, const bitset *w) {
    e[++ecnt].v = v, e[ecnt].nxt = heads[u], heads[u] = ecnt;
    e[ecnt].w = w;
  }
} G;

namespace Tree {

bitset dis[MAXN];
Graph G;

void dfs(int u, int fa) {
  for (int i = G(u); i; i = G[i].nxt) {
    int v = G[i].v;
    if (v != fa) {
      dis[v] = dis[u] ^ (*G[i].w);
      dfs(v, u);
    }
  }
}

}  // namespace Tree
using Tree::dis;

struct Basis {
  bitset base[LEN];

  inline void insert(bitset x) {
    for (int i = LEN - 1; i >= 0; --i) {
      if (x[i]) {
        if (base[i].any() == false) {
          base[i] = x;
          break;
        }
        x ^= base[i];
      }
    }
  }

  inline bitset query() const {
    bitset res;
    for (int i = LEN - 1; i >= 0; --i)
      if (res[i] == false && base[i].any()) res ^= base[i];
    return res;
  }
} global;

std::vector<const bitset *> vec[MAXQ * 4];

void insert(int x, int l, int r, int L, int R, const bitset *val) {
  if (L <= l && r <= R) return vec[x].push_back(val);
  int mid = (l + r) >> 1;
  if (L <= mid) insert(x << 1, l, mid, L, R, val);
  if (mid < R) insert(x << 1 | 1, mid + 1, r, L, R, val);
}

void println(const bitset &x) {
  int i;
  for (i = LEN - 1; i >= 0; --i)
    if (x[i]) break;
  if (i < 0) cout << '0';
  while (i >= 0) cout << x[i--];
  cout << '\n';
}

void solve(int x, int l, int r, Basis basis) {
  for (auto w : vec[x]) basis.insert(*w);
  if (l == r) {
    println(basis.query());
    return;
  }
  int mid = (l + r) >> 1;
  solve(x << 1, l, mid, basis);
  solve(x << 1 | 1, mid + 1, r, basis);
}

struct Event {
  int start, end;
  bitset w;
};

int u[MAXN], v[MAXN];
int start[MAXQ], end[MAXQ];
bitset highway[MAXQ];
std::vector<Event> q;

inline int main() {
  int n, m, P;
  cin >> n >> m >> P;
  for (int i = 1; i <= m; ++i) {
    cin >> u[i] >> v[i] >> w[i];
    G.add(u[i], v[i], &w[i]);
    G.add(v[i], u[i], &w[i]);
  }
  UFS::init(n);
  for (int i = 1; i <= m; ++i) {
    int x = u[i], y = v[i];
    int fx = find(x), fy = find(y);
    if (fx != fy) {
      UFS::fa[fx] = fy;
      Tree::G.add(x, y, &w[i]), Tree::G.add(y, x, &w[i]);
    }
  }
  Tree::dfs(1, 1);
  for (int i = 1; i <= m; ++i) {
    global.insert(dis[u[i]] ^ dis[v[i]] ^ w[i]);
  }
  char opt[7];
  int addcnt = 0;
  for (int x, y, i = 1; i <= P; ++i) {
    cin >> opt >> x;
    switch (opt[1]) {
      case 'd':
        ++addcnt;
        cin >> y >> highway[addcnt];
        u[addcnt] = x, v[addcnt] = y;
        start[addcnt] = i;
        break;
      case 'a':
        end[x] = i - 1;
        q.push_back(Event{start[x], end[x], dis[u[x]] ^ dis[v[x]] ^ highway[x]});
        break;
      case 'h':
        q.push_back(Event{start[x], i - 1, dis[u[x]] ^ dis[v[x]] ^ highway[x]});
        cin >> highway[x];
        start[x] = i, end[x] = 0;
        break;
    }
  }
  for (int i = 1; i <= addcnt; ++i) {
    if (end[i] == 0) q.push_back(Event{start[i], P, dis[u[i]] ^ dis[v[i]] ^ highway[i]});
  }
  for (const auto &i : q) insert(1, 1, P, i.start, i.end, &i.w);
  println(global.query());
  if (P != 0) solve(1, 1, P, global);
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3733 [HAOI2017] 八纵八横.in", "r", stdin);
  freopen("P3733 [HAOI2017] 八纵八横.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
